package leetcode_acm.array;

/**
 * 功能描述
 *
 * @author: 张庭杰
 * @date: 2023年03月17日 15:27
 */
public class IsPerfectSquare {
    public boolean isPerfectSquare(int num) {
        int l = 0, r = num;
        while(l <= r){
            int mid = l+((r-l)>>1);
            long sqrt = (long) mid *mid;
            if(sqrt == num){
                return true;
            }else if(sqrt < num){
                l = mid+1;
            }else{
                r = mid-1;
            }
        }
        return false;
    }
}
